import Dayjs from 'dayjs'

if (import.meta.env.DEV || __ENV__.VITE_DEV_TOOLS === 'true') {
  import('vconsole').then(({ default: VConsole }) => {
    new VConsole({
      onReady() {
        const box = document.querySelector('#__vconsole>.vc-switch')
        if (!box) return
        // 新增构建时间显示
        const time = document.createElement('div')
        time.innerText = Dayjs(__BUILD_TIME__).format('YY/MM/DD HH:mm:ss')
        time.style.cssText = 'font-size: 0.7em;opacity: 0.7;margin: 0 -1em;'
        box.appendChild(time)
        // 新增分支显示
        const branch = document.createElement('div')
        branch.innerText = __GIT_BRANCH__
        branch.style.cssText = 'font-size: 0.7em;opacity: 0.7;margin: -3.2em -1.5em 1.5em;'
        box.appendChild(branch)
      },
    })
  })
}
